<table width="100%" cellspacing="15">
  <tr>
   <td width="100%" valign="top">
      <div class="gray_box" style="">
        <table width="100%" height="500" cellpadding="2" cellspacing="1" border="0" >
         <form name='edit_cms' action="" method="POST" >
        <input type="hidden" name="page_id" value="<?php echo $page_data[page_id]; ?>">
          <tr>
            <td valign="top" colspan="2" style="padding:15px" ><?php echo  $page_data[page][page_url]?></td>
          </tr>
           <tr>
            <td valign="top" colspan="2" ><h4>Edit Page Contents</h4></td>
          </tr>
          <?php if ($page_data[errors] != '') { ?>
            <tr>
              <td valign="top" colspan="2" style="color: #ff0000;"><?php echo $page_data[errors];?></td>
            </tr>
          <?php } // end if errors

              ?>
          <tr>
            <td valign="top" width="10%">Header:</td>
            <td valign="top" width="90%">
            <textarea name="page_header" style="width:600px;height:300px" ><?php echo  $page_data[page][page_header]?><?php echo  $page_data[start_flag]?></textarea>



           </tr>
          <tr>
          <tr>
            <td valign="top">Body:</td>
            <td valign="top">
             <textarea name="page_body" style="width:600px;height:300px" ><?php echo  $page_data[page][page_body]?></textarea>

        </td>
          </tr>
          <tr>
            <td valign="top">Footer:</td>
            <td valign="top">
            <textarea name="page_footer" style="width:600px;height:300px" ><?php echo  $page_data[end_flag]?><?php echo  $page_data[page][page_footer]?></textarea>

 </td>
          </tr>

		  <tr>
            <td valign="top" colspan="2" align="center">

               <input type="button" onclick="return mypreview('p')" value="Preview" >
              <input type="button" onclick="return mypreview('s')" name="aaaa" value="Submit">
              <input type="button" onclick="window.location='<?php echo $_SERVER['PHP_SELF'];?>'" value="Cancel">
            </td>
          </tr>
          </form>

        </table>
      </div>
    </td>
  </tr>
</table>
<script>
function mypreview(val)
{

 if(val == 's'){
  document.edit_cms.action ='<?php echo $_SERVER['PHP_SELF'];?>?task=update';
  document.edit_cms.submit();

 }else{
  document.edit_cms.target = 'newwin';
  document.edit_cms.action ='../templates/html_content/update_preview.php';
  window.open('update_preview.php','newwin','');
  document.edit_cms.submit();

 }
}
</script>